package com.ruoyi.system.outto.game.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.model.domain.AccountInfo;
import com.ruoyi.system.model.domain.InfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.model.mapper.SuprAuthMapper;
import com.ruoyi.system.outto.core.KGHConstant;
import com.ruoyi.system.outto.core.WYConstant;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.core.OutUrlConstant;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.game.WUYOUAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/6/5 16:19
 */
@Slf4j
@Service
public class WUYOUAPIImpl implements WUYOUAPI {

    @Resource
    private InfoImgMapper infoImgMapper;
    @Resource
    private SuprAuthMapper suprAuthMapper;
    @Resource
    private CommonApi commonApi;
    @Value("${desc.title}")
    private String descTitle;
    private SalePartner salePartner;

    @Override
    public AjaxResult addGame(AccountInfo accountInfo, Long userId,SalePartner salePartner) {
        this.salePartner = salePartner;
        Map<String, Object> params = params(accountInfo, "add",salePartner);
        Map<String, Object> result = new HashMap<>();
        String response = HttpUtils.doPostForm(salePartner.getOther(), params,null);
        log.info("无忧添加接口请求参数={}", JSONObject.toJSONString(params));
        log.info("无忧添加接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if(!Objects.isNull(resultJson)) {
            if (!"true".equals(resultJson.getString("succ"))) {
                result.put("code" , 500);
            } else {
                result.put("code" , 200);
            }
            result.put("msg", resultJson.getString("msg"));
        }else{
            result.put("code" , 500);
            result.put("msg", "添加失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult editGame(AccountInfo accountInfo, Long userId,SalePartner salePartner) {
        this.salePartner = salePartner;
        Map<String, Object> params = params(accountInfo, "update",salePartner);
        Map<String, Object> result = new HashMap<>();
        String response = HttpUtils.doPostForm(salePartner.getOther(), params,null);
        log.info("无忧编辑接口请求参数={}", JSONObject.toJSONString(params));
        log.info("无忧编辑接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if(!Objects.isNull(resultJson)) {
            if (!"true".equals(resultJson.getString("succ"))) {
                result.put("code" , 500);
            } else {
                result.put("code" , 200);
            }
            result.put("msg", resultJson.getString("msg"));
        }else{
            result.put("code" , 500);
            result.put("msg", "编辑失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        return AjaxResult.success(result);
    }


    private Map<String, Object> params(AccountInfo accountInfo, String type,SalePartner salePartner) {
        Map<String, Object> params = new HashMap<>();
        params.put("key", salePartner.getSaleKey());
        params.put("merchant_no", salePartner.getTwoOther());
        params.put("pid",accountInfo.getId());
        params.put("title",accountInfo.getDes());

        BigDecimal bigDecimal = commonApi.addPrice(accountInfo.getPrice(),  salePartner.getSeleep());
        commonApi.setPrice(bigDecimal,accountInfo.getId(), salePartner);
        params.put("price",bigDecimal);

        InfoImg infoImg = new InfoImg();
        infoImg.setInfoId(accountInfo.getId());
        infoImg.setType(Constants.STR_1);
        List<InfoImg> infoImgs = infoImgMapper.selectInfoImgList(infoImg);
        String pic = "";
        if (Objects.nonNull(accountInfo.getTitleImg())){
            pic = accountInfo.getTitleImg() + ",";
        }
        if (!CollectionUtils.isEmpty(infoImgs)) {
            pic = pic + infoImgs.stream().map(i -> i.getImgUrl()).collect(Collectors.joining(","));
        } else {
            pic =  pic + LCConstant.defaultImg;
        }
        params.put("pic", pic);
        params.put("paiwei","可排位");
        if(accountInfo.getLevel().equals("包人脸")){
            params.put("smstate",2);
        }else if(accountInfo.getLevel().equals("有二次")){
            params.put("smstate",1);
        }else{
            params.put("smstate",0);
        }
        params.put("account",descTitle+accountInfo.getId());
        params.put("type",type);
        if("王者荣耀".equals(accountInfo.getType())) {
            params.put("gameid", "3");
            //游戏大区
            String youxidaqu = youxiqufu(3);
            JSONObject wzresult = JSONObject.parseObject(youxidaqu);
            JSONArray options = JSONObject.parseArray((wzresult.get("arealist")).toString());
            for(Object o : options){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(String.valueOf(jsonObject1.get("name")).contains(accountInfo.getRegional().replace("WX","微信"))){
                    params.put("serverid",Integer.parseInt(jsonObject1.getString("id")));
                }
            }
            //扩展属性
            List<String> dcpf = new ArrayList<>();
            List<String> xyzc = new ArrayList<>();
            List<String> jppf = new ArrayList<>();
            List<String> zljp = new ArrayList<>();
            List<String> zbg = new ArrayList<>();
            String respones = kuozhanshuxing(3);
            JSONObject kuozhanshuxingResult = JSONObject.parseObject(respones);
            JSONArray kuozhanshuxing = JSONObject.parseArray(kuozhanshuxingResult.get("data").toString());
            for(Object o : kuozhanshuxing){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(jsonObject1.get("propertyname").equals("典藏皮肤")) {
                    //典藏皮肤
                    JSONArray diancangpifuArray = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : diancangpifuArray){
                        JSONObject diancangpifu = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(diancangpifu.getString("key"))){
                            dcpf.add(diancangpifu.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("星元珍藏")) {
                    //星元珍藏
                    JSONArray diancangpifuArray = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : diancangpifuArray){
                        JSONObject diancangpifu = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(diancangpifu.getString("key"))){
                            xyzc.add(diancangpifu.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("精品皮肤")) {
                    //精品皮肤
                    JSONArray diancangpifuArray = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : diancangpifuArray){
                        JSONObject diancangpifu = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(diancangpifu.getString("key"))){
                            jppf.add(diancangpifu.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("战令精品")) {
                    //战令精品
                    JSONArray diancangpifuArray = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : diancangpifuArray){
                        JSONObject diancangpifu = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(diancangpifu.getString("key"))){
                            zljp.add(diancangpifu.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("珍宝阁")) {
                    //珍宝阁
                    JSONArray diancangpifuArray = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : diancangpifuArray){
                        JSONObject diancangpifu = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(diancangpifu.getString("key"))){
                            zbg.add(diancangpifu.getString("value"));
                        }
                    }
                }
                String pawei = "paiwei=可排位";
                String optionss = pawei;
                if(StringUtils.isNotEmpty(dcpf)){
                    String join = StringUtils.join(dcpf, ",");
                    String remenshizhuang = "典藏皮肤=" + join;
                    optionss+= "|" + remenshizhuang;
                }
                if(StringUtils.isNotEmpty(xyzc)){
                    String join1 = StringUtils.join(xyzc, ",");
                    String xingyuanzhencang = "星元珍藏=" + join1;
                    optionss+= "|" + xingyuanzhencang;
                }
                if(StringUtils.isNotEmpty(jppf)){
                    String join2 = StringUtils.join(jppf, ",");
                    String jingpinpifu = "精品皮肤=" + join2;
                    optionss+= "|" + jingpinpifu;
                }
                if(StringUtils.isNotEmpty(zljp)){
                    String join3 = StringUtils.join(zljp, ",");
                    String zhanlingjingpin = "战令精品=" + join3;
                    optionss+= "|" + zhanlingjingpin;
                }
                if(StringUtils.isNotEmpty(zbg)){
                    String join4 = StringUtils.join(zbg, ",");
                    String zhenbaoge = "珍宝阁=" + join4;
                    optionss+= "|" + zhenbaoge;
                }
                params.put("options",optionss.replace("null",""));
            }

        }else if("和平精英".equals(accountInfo.getType())){
            params.put("gameid", "5");
            //游戏大区
            String response = youxiqufu(5);
            JSONObject wzresult = JSONObject.parseObject(response);
            JSONArray options = JSONObject.parseArray((wzresult.get("arealist")).toString());
            for(Object o : options){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(jsonObject1.get("name").toString().contains(accountInfo.getRegional().replace("WX","微信"))){
                    params.put("serverid",Integer.parseInt(jsonObject1.getString("id")));
                }
            }
            //扩展属性
            List<String> rmsz = new ArrayList<>();
            List<String> xyqp = new ArrayList<>();
            List<String> xyzj = new ArrayList<>();
            String responsee = kuozhanshuxing(5);
            JSONObject resultJson1 = JSONObject.parseObject(responsee);
            JSONArray array = JSONArray.parseArray(resultJson1.get("data").toString());
            for(Object o : array){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(jsonObject1.getString("propertyname").equals("热门时装")){
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options1){
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenjuji.getString("key"))){
                            rmsz.add(remenjuji.getString("value"));
                        }
                    }
                }
                if(jsonObject1.getString("propertyname").equals("稀有枪皮")){
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options1){
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenjuji.getString("key"))){
                            xyqp.add(remenjuji.getString("value"));
                        }
                    }
                }
                if(jsonObject1.getString("propertyname").equals("稀有载具")){
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options1){
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenjuji.getString("key"))){
                            xyzj.add(remenjuji.getString("value"));
                        }
                    }
                }
                String pawei = "paiwei=可排位";
                String optionss =pawei;
                if(StringUtils.isNotEmpty(rmsz)){
                    String join = StringUtils.join(rmsz, ",");
                    String remenshizhuang = "热门时装=" + join;
                    optionss+= "|" +remenshizhuang;
                }
                if(StringUtils.isNotEmpty(xyqp)){
                    String join1 = StringUtils.join(xyqp, ",");
                    String xiyouqiangpi = "稀有枪皮=" + join1;
                    optionss += "|" + xiyouqiangpi;
                }
                if(StringUtils.isNotEmpty(xyzj)){
                    String join2 = StringUtils.join(xyzj, ",");
                    String xiyouzaiju = "稀有载具=" + join2;
                    optionss += "|" + xiyouzaiju;
                }
                params.put("options",optionss);
            }
        }else if("CF端游".equals(accountInfo.getType())){
            params.put("gameid", "1");
            //游戏大区
            String daquresponse =  youxiqufu(1);
            JSONObject cfresult = JSONObject.parseObject(daquresponse);
            JSONArray cfdaqu = JSONObject.parseArray((cfresult.get("arealist")).toString());
            for(Object o : cfdaqu){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(accountInfo.getDes().contains(jsonObject1.getString("name"))){
                    params.put("serverid",Integer.parseInt(jsonObject1.getString("id")));
                }
            }
            String pawei = "排位=可排位";
            List<String> huanshen = new ArrayList<>();
            List<String> pifu = new ArrayList<>();
            List<String> yxb = new ArrayList<>();
            List<String> rmwq = new ArrayList<>();
            List<String> rmsq = new ArrayList<>();
            List<String> rmsl = new ArrayList<>();
            List<String> rmrw = new ArrayList<>();
            List<String> bzsh = new ArrayList<>();
            List<String> tzds = new ArrayList<>();
            String response = kuozhanshuxing(1);
            JSONObject resultJson1 = JSONObject.parseObject(response);
            JSONArray youxizhanghao = JSONObject.parseArray(resultJson1.get("data").toString());
            for (Object o : youxizhanghao){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(jsonObject1.get("propertyname").equals("热门狙击")){
                    //热门狙击
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenjuji.getString("key"))){
                            huanshen.add(remenjuji.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("热门皮肤")){
                    //热门皮肤
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject remenpifu = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenpifu.getString("key"))){
                            pifu.add(remenpifu.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("音效卡")){
                    //音效卡
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject yinxiaoka = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(yinxiaoka.getString("key"))){
                            yxb.add(yinxiaoka.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("热门武器")){
                    //热门武器
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject remenwuqi = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenwuqi.getString("key"))){
                            rmwq.add(remenwuqi.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("热门手枪")){
                    //热门手枪
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject remenshouqiang = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenshouqiang.getString("key"))){
                            rmsq.add(remenshouqiang.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("热门手雷")){
                    //热门手雷
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject remenshoulei = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenshoulei.getString("key"))){
                            rmsl.add(remenshoulei.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("热门人物")){
                    //热门人物
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject remenrenwu = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenrenwu.getString("key"))){
                            rmrw.add(remenrenwu.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("暴走生化")){
                    //暴走生化
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject baozoushenghua = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(baozoushenghua.getString("key"))){
                            bzsh.add(baozoushenghua.getString("value"));
                        }
                    }
                }
                if(jsonObject1.get("propertyname").equals("挑战大师")){
                    //挑战大师
                    JSONArray options = JSONObject.parseArray((jsonObject1.get("options")).toString());
                    for(Object a : options){
                        JSONObject tiaozhandashi = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(tiaozhandashi.getString("key"))){
                            tzds.add(tiaozhandashi.getString("value"));
                        }
                    }
                }
            }
            String options = pawei;
            if(StringUtils.isNotEmpty(huanshen)){
                String join = StringUtils.join(huanshen, ",");
                String remenjuji = "热门狙击=" + join;
                options+="|"+remenjuji;
            }
            if(StringUtils.isNotEmpty(pifu)){
                String join1 = StringUtils.join(pifu, ",");
                String remenpifu = "热门皮肤=" + join1;
                options+="|"+remenpifu;
            }
            if(StringUtils.isNotEmpty(yxb)){
                String join2 = StringUtils.join(yxb, ",");
                String yinxiaoka = "音效卡=" + join2;
                options+="|"+yinxiaoka;
            }
            if(StringUtils.isNotEmpty(rmwq)){
                String join3 = StringUtils.join(rmwq, ",");
                String remenwuqi = "热门武器=" + join3;
                options+="|"+remenwuqi;
            }
            if(StringUtils.isNotEmpty(rmsq)){
                String join4 = StringUtils.join(rmsq, ",");
                String remenshouqiang = "热门手枪=" + join4;
                options+="|"+remenshouqiang;
            }
            if(StringUtils.isNotEmpty(rmsl)){
                String join5 = StringUtils.join(rmsl, ",");
                String remenshoulei = "热门手雷=" + join5;
                options+="|"+remenshoulei;
            }
            if(StringUtils.isNotEmpty(rmrw)){
                String join6 = StringUtils.join(rmrw, ",");
                String renmenrenwu = "热门人物=" + join6;
                options+="|"+renmenrenwu;
            }
            if(StringUtils.isNotEmpty(bzsh)){
                String join7 = StringUtils.join(bzsh, ",");
                String baozoushenghua = "暴走生化=" + join7;
                options+="|"+baozoushenghua;
            }
            if(StringUtils.isNotEmpty(tzds)){
                String join8 = StringUtils.join(tzds, ",");
                String tiaozhandashi = "挑战大师=" + join8;
                options+="|"+tiaozhandashi;
            }
            params.put("options",options.replaceAll(" ",""));
        }else if("CF手游".equals(accountInfo.getType())){
            //CF手游
            params.put("gameid", "2");
            //游戏大区
            String daquresponse =  youxiqufu(2);
            JSONObject wzresult = JSONObject.parseObject(daquresponse);
            JSONArray options = JSONObject.parseArray((wzresult.get("arealist")).toString());
            for(Object o : options){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(jsonObject1.get("name").toString().contains(accountInfo.getRegional().replace("WX","微信"))){
                    params.put("serverid",Integer.parseInt(jsonObject1.getString("id")));
                }
            }
            //扩展属性
            List<String> zzt = new ArrayList<>();
            List<String> rmwq = new ArrayList<>();
            String cfsyoptions = kuozhanshuxing(2);
            JSONObject wzresults = JSONObject.parseObject(cfsyoptions);
            JSONArray cfdaqu = JSONObject.parseArray((wzresults.get("data")).toString());
            for(Object o:cfdaqu) {
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(jsonObject1.getString("propertyname").equals("至尊套")){
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for(Object a : options1){
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenjuji.getString("key"))){
                            zzt.add(remenjuji.getString("value"));
                        }
                    }
                }
                if(jsonObject1.getString("propertyname").equals("热门武器")){
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for(Object a : options1){
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if(accountInfo.getDes().contains(remenjuji.getString("key"))){
                            rmwq.add(remenjuji.getString("value"));
                        }
                    }
                }
            }
            String pawei = "paiwei=可排位";
            String optionss =pawei;
            if(StringUtils.isNotEmpty(zzt)){
                String join = StringUtils.join(zzt, ",");
                String zhizuntao = "至尊套=" + join;
                optionss+= "|" +zhizuntao;
            }
            if(StringUtils.isNotEmpty(rmwq)){
                String join1 = StringUtils.join(rmwq, ",");
                String remenwuqi = "热门武器=" + join1;
                optionss += "|" + remenwuqi;
            }
            params.put("options",optionss.replaceAll(" ",""));
        }else if("原神".equals(accountInfo.getType())){
            //原神
            params.put("gameid", "6");
            //游戏大区
            String daquresponse =  youxiqufu(6);
            JSONObject ysresult = JSONObject.parseObject(daquresponse);
            JSONArray options = JSONObject.parseArray((ysresult.get("arealist")).toString());
            for(Object o : options){
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if(jsonObject1.getString("name").contains(accountInfo.getRegional())){
                    params.put("serverid",Integer.parseInt(jsonObject1.getString("id")));
                }
            }
            //扩展属性
            List<String> bdqk = new ArrayList<>();
            List<String> upjs = new ArrayList<>();
            List<String> czjs = new ArrayList<>();
            List<String> wxgjwq = new ArrayList<>();
            List<String> wxdsj = new ArrayList<>();
            List<String> wxssj = new ArrayList<>();
            List<String> wxfq = new ArrayList<>();
            List<String> wxcbwq = new ArrayList<>();
            String yskzsx = kuozhanshuxing(6);
            JSONObject wzresults = JSONObject.parseObject(yskzsx);
            JSONArray yskzsxx = JSONObject.parseArray((wzresults.get("data")).toString());
            //绑定情况
            if (LCConstant.rezhengMial.equals(accountInfo.getLevel())) {
                bdqk.add("已实名邮");
            } else if (LCConstant.noMial.equals(accountInfo.getLevel())) {
                bdqk.add("未实名邮");
            } else if (LCConstant.nobanggMial.equals(accountInfo.getLevel())) {
                bdqk.add("未绑定邮");
            }
            for(Object o:yskzsxx) {
                JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
                if (jsonObject1.getString("propertyname").equals("UP角色")) {
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for (Object a : options1) {
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if (accountInfo.getDes().contains(remenjuji.getString("key"))) {
                            upjs.add(remenjuji.getString("value"));
                        }
                    }
                }
                if (jsonObject1.getString("propertyname").equals("常驻角色")) {
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for (Object a : options1) {
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if (accountInfo.getDes().contains(remenjuji.getString("key"))) {
                            czjs.add(remenjuji.getString("value"));
                        }
                    }
                }
                if (jsonObject1.getString("propertyname").equals("五星弓箭武器")) {
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for (Object a : options1) {
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if (accountInfo.getDes().contains(remenjuji.getString("key"))) {
                            wxgjwq.add(remenjuji.getString("value"));
                        }
                    }
                }
                if (jsonObject1.getString("propertyname").equals("五星单手剑")) {
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for (Object a : options1) {
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if (accountInfo.getDes().contains(remenjuji.getString("key"))) {
                            wxdsj.add(remenjuji.getString("value"));
                        }
                    }
                }
                if (jsonObject1.getString("propertyname").equals("五星双手剑")) {
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for (Object a : options1) {
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if (accountInfo.getDes().contains(remenjuji.getString("key"))) {
                            wxssj.add(remenjuji.getString("value"));
                        }
                    }
                }
                if (jsonObject1.getString("propertyname").equals("五星法器")) {
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for (Object a : options1) {
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if (accountInfo.getDes().contains(remenjuji.getString("key"))) {
                            wxfq.add(remenjuji.getString("value"));
                        }
                    }
                }
                if (jsonObject1.getString("propertyname").equals("五星长柄武器")) {
                    JSONArray options1 = JSONObject.parseArray((jsonObject1.getString("options")));
                    for (Object a : options1) {
                        JSONObject remenjuji = JSONObject.parseObject(JSONObject.toJSONString(a));
                        if (accountInfo.getDes().contains(remenjuji.getString("key"))) {
                            wxcbwq.add(remenjuji.getString("value"));
                        }
                    }
                }
            }
            String shifoukejihao = "是否科技号=否";
            String optionss =shifoukejihao;
            if(StringUtils.isNotEmpty(bdqk)){
                String join = StringUtils.join(bdqk, ",");
                String bangdingqingkuang = "绑定情况=" + join;
                optionss+= "|" +bangdingqingkuang;
            }
            if(StringUtils.isNotEmpty(upjs)){
                String join1 = StringUtils.join(upjs, ",");
                String upjuese = "UP角色=" + join1;
                optionss += "|" + upjuese;
            }
            if(StringUtils.isNotEmpty(czjs)){
                String join2 = StringUtils.join(czjs, ",");
                String changzhujuese = "常驻角色=" + join2;
                optionss += "|" + changzhujuese;
            }
            if(StringUtils.isNotEmpty(wxgjwq)){
                String join3 = StringUtils.join(czjs, ",");
                String wuxinggjwq = "五星弓箭武器=" + join3;
                optionss += "|" + wuxinggjwq;
            }
            if(StringUtils.isNotEmpty(wxdsj)){
                String join4 = StringUtils.join(czjs, ",");
                String wuxingdsj = "五星单手剑=" + join4;
                optionss += "|" + wuxingdsj;
            }
            if(StringUtils.isNotEmpty(wxssj)){
                String join5 = StringUtils.join(wxssj, ",");
                String wuxingssj = "五星双手剑=" + join5;
                optionss += "|" + wuxingssj;
            }
            if(StringUtils.isNotEmpty(wxfq)){
                String join6 = StringUtils.join(wxfq, ",");
                String wuxingfq = "五星法器=" + join6;
                optionss += "|" + wuxingfq;
            }
            if(StringUtils.isNotEmpty(wxcbwq)){
                String join7 = StringUtils.join(wxcbwq, ",");
                String wuxingcbwq = "五星长柄武器=" + join7;
                optionss += "|" + wuxingcbwq;
            }
            params.put("options",optionss.replaceAll(" ",""));
        }
        return params;
    }

    @Override
    public AjaxResult delGame(AccountInfo accountInfo, Long userId,SalePartner salePartner) {
        this.salePartner = salePartner;
        Map<String, Object> params = params(accountInfo, "delete",salePartner);
        Map<String, Object> result = new HashMap<>();
        String response = HttpUtils.doPostForm(salePartner.getOther(), params,null);
        log.info("无忧删除接口请求参数={}", JSONObject.toJSONString(params));
        log.info("无忧删除接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!Objects.isNull(resultJson)){
            if (!"true".equals(resultJson.getString("succ"))) {
                result.put("code", 500);
            } else {
                result.put("code", 200);
            }
            result.put("msg", resultJson.getString("msg"));
        }else {
            result.put("code", 500);
            result.put("msg", "删除失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);

        return AjaxResult.success(result);
    }

    public static void main(String[] args) {

        /*JSONObject resultJson1 = JSONObject.parseObject(response);
        System.out.println(resultJson1);
        JSONArray array = JSONArray.parseArray(resultJson1.get("data").toString());
        for(Object o : array){
            System.out.println(JSONObject.parseObject(o.toString()).get("propertyname"));
        }*/
        /*JSONObject resultJson1 = JSONObject.parseObject(response);
        JSONArray jsonArray = JSONArray.parseArray(resultJson1.getString("arealist"));
        for (Object o : jsonArray){
            System.out.println(o);
        }*/
        Map<String, Object> params1 = new TreeMap<>();
        params1.put("secretKey","9677890fc5aeb95c4c1f189640846bfd");
        params1.put("type","AddGame");
        String response = HttpUtils.doPostForm("http://kaka.bumihu.cn/api/partner/wz.php", params1,null);

        System.out.println(response);
    }

    public static String kuozhanshuxing(int type){
        Map<String, Object> params1 = new TreeMap<>();
        Map<String, Object> head = new HashMap<>();
        head.put("content-type", "application/x-www-form-urlencoded");
        params1.put("key","8342BB6C12B595E0");
        params1.put("merchant_no","zhongduan");
        params1.put("gameid",type);
        params1.put("content-type", "application/x-www-form-urlencoded");
        String response = HttpUtils.doPostForm("http://api2.juhuanyou.com/tools/getExpendAttribute.ashx", params1,head);
        return response;
    }
    public static String youxiqufu(int type){
        Map<String, Object> params1 = new TreeMap<>();
        Map<String, Object> head = new HashMap<>();
        head.put("content-type", "application/x-www-form-urlencoded");
        params1.put("key","8342BB6C12B595E0");
        params1.put("merchant_no","zhongduan");
        params1.put("gameid",type);
        params1.put("content-type", "application/x-www-form-urlencoded");
        String response = HttpUtils.doPostForm("http://api2.juhuanyou.com/tools/getAreaServer.ashx", params1,head);
        return response;
    }

}
